package com.blacktea.behavioralpatterns.mediatorpattern.service;

import com.blacktea.behavioralpatterns.mediatorpattern.Book;
import com.blacktea.behavioralpatterns.mediatorpattern.BookService;
import com.blacktea.behavioralpatterns.mediatorpattern.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @description:
 * @author: black tea
 * @date: 2023/3/25 16:48
 */
@Service
public class BorrowService {

    @Autowired
    private BookService bookService;

    @Autowired
    private UserService userService;

    public void borrow(Book book, String borrower) {
        // 借书
        book.setBorrower(borrower);
        bookService.borrowBook(book);
    }

    public void returnBook(Book book) {
        // 还书
        book.setBorrower(null);
        bookService.returnBook(book);
    }
}
